package com.py.chat.server.businese;

import com.google.protobuf.MessageLite;
import com.py.chat.bean.ChatLog;
import com.py.chat.bean.Gloable;
import com.py.chat.proto.ChatProbuf;
import com.py.chat.proto.ChatProbuf.CTSChatLogs;
import com.py.chat.proto.ChatProbuf.STCChatLogsRet;
import com.py.chat.proto.IBusineseHandle;
public class ServerChatLogsHandle extends IBusineseHandle<CTSChatLogs>{

	@Override
	public MessageLite handle(CTSChatLogs msg) {
		STCChatLogsRet.Builder builder = STCChatLogsRet.newBuilder();
		if(session.user == null){
			return builder.setStatus(0).setMsg("用户未登录").build();
		}
		for(ChatLog chatLog:Gloable.chatLogList){
			builder.setStatus(1).addChatLogs(ChatProbuf.ChatLog.newBuilder().
					setMsg(chatLog.getMsg()).
					setSendUserName(chatLog.getUser().getName()).
					setCreateDate(chatLog.getCreateDate()).
					setSendUserLevel(chatLog.getUser().getLevel()).build());	
		}
		return builder.build();
	}
}
